<html>
<head>
    <title>金字塔</title>
    <meta charset="UTF-8">
    <style>
        .box{background-color:#000000;margin:3px;padding: 2px;
        foot-size:24px;font-weight: bold;color:#FFF000;}
        .out{border:solid 3px #000;float:left;overflow: hidden;margin:auto;}
    </style>
</head>
<body>
<div class="out">
    <div class="box">
<?php
$line =1;
while($line<=5){
    //初始化金字塔中每行的空格和星星的数量；
    $empty_pos=$star_pos=1;
    $empty=5-$line;
    //计算：每行的星星数=当前行数*2-1；
    $star =2*$line-1;
    while($empty_pos<=$empty){
        echo  '&nbsp;';
        ++$empty_pos;
    }
    while ($star_pos<=$star){
        echo '*';
        ++$star_pos;
    }
    echo '<br>';
    ++$line;
}
?>
        </div>
    </div>
</body>
</html>
